<template>
  <div>
    <i-frame :src="reportUrl"></i-frame>
  </div>
</template>
<script>
import { getToken } from "@/utils/auth";
import iFrame from "@/components/iFrame/index";
export default {
  name: "PyJeecgReportView",
  components: { iFrame },
  data() {
    return {
      reportUrl: ""
    }
  },
  created() {
    let query = this.$route.query;
    // let code = undefined;
    let code = "1128203778660184064";  //写死对应页面code就是对应的页面,如果通过按钮传递参数,则是选择的页面的
    let paramsString = "";
    if (query) {
      for (const key in query) {
        if (Object.hasOwnProperty.call(query, key)) {
          const param = query[key];
          if (key == "code") {
            code = param;
          } else {
            if (paramsString != "") {
              paramsString += paramsString + "&" + key + "=" + param;
            } else {
              paramsString = "&" + key + "=" + param;
            }
          }

        }
      }
    }

    if (code) {
      this.reportUrl = process.env.VUE_APP_BASE_API + "/jmreport/view/" + code + "?token=Bearer " + getToken() + paramsString;

    } else {
      this.$modal.msgError("报表编码(code)为空，无法打开报表");
    }
  }
}
</script>
